<template>
	<view>
		<uni-list v-for="(item,index) in list" :key="index">
			<view @longpress="longpress(item.id)">
				<uni-list-item clickable :title="item.ProductCode" :show-badge="true" :note="item.ProductName"
					:rightText="item.note"></uni-list-item>
			</view>

		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				list: [],
				hid:'',
				WarehouseId:'',

			}
		},
		onLoad(param) {
            this.hid=param.id
			this.WarehouseId=param.WarehouseId
			this.$api.Request({
				url: "/api/input/GetInputbodyList?keyword=" + param.id,
				method: 'GET',

			}).then((res) => {

				res.forEach(item => {

					this.list.push({
						id: item.Id,
						ProductCode: "物料编码: " + item.ProductCode,
						ProductName: "名称: " + item.ProductName + " 规格：" + item.Cinvstd + " 批次：" +
							item.Batch,
						note: "数量: " + item.Number + "/" + item.CinvmUnit

					})
				});

			})


		},


		methods: {
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url: '../inputbodyadd/inputbodyadd?hid='+this.hid+'&WarehouseId='+this.WarehouseId,
			})
		},
			longpress(id) {
				var me = this;
				uni.showModal({
					title: '删除',
					content: '请问要删除本条消息吗？',
					success: function(res) {
						if (res.confirm) {
							me.$api.Request({
								url: "/api/input/DeleteBody?keyValue=" + id,
								method: 'GET',

							}).then((res1) => {

								if (res1.state == 'success') {
									uni.showToast({
										title: `删除成功`
									})
									location.reload();

								} else {
									uni.showToast({
										title: `删除失败`,
										icon:'error',
									})

								}

							})
						}
					}
				});
			}
		},


	}
</script>

<style>

</style>
